<template>
    <scroll-view 
        :scroll-y="true"
        class="yfyp_cp">
        <view class="container">
            <view class="title el-after">
                已结账用户
            </view>
            <view class="two">
                <u-table>
                    <u-tr>
                        <u-th>卡号</u-th>
                        <u-th>挂号单</u-th>
                        <u-th>姓名</u-th>
                        <u-th>性别</u-th>
                        <u-th>年龄</u-th>
                    </u-tr>
                    <u-tr 
                        v-for="(item,index) in dataList" 
                        :key="index"
                        @click.native="findDetail(item)">
                        <u-td>{{item["卡号"]}}</u-td>
                        <u-td>{{item["挂单号"]}}</u-td>
                        <u-td>{{item["姓名"]}}</u-td>
                        <u-td>{{item["性别"]}}</u-td>
                        <u-td>{{item["年龄"]}}</u-td>
                    </u-tr>
                </u-table>
            </view>
            <view class="bt_list">
                <u-button 
                    type="success"
                    :loading="loading"
                    @click="getData">
                    刷新
                </u-button>
            </view>
            <u-toast ref="uToast" />
        </view>
    </scroll-view>
</template>

<script>
//已发药品组件
import {getPayUpUsers} from "@/common/api"
export default {
    props:{
        show:{  //当前页是否显示
            type:Boolean,
            default:false,
        },
        pageShow:{  //当前页面是否显示
            type:Boolean,
            default:false,
        },
    },
    data() {
        return {
            dataList:[],  //数据列表
            loading:false,
        }
    },
    watch:{
        show:{
            handler(newValue){
                //当该页可见时获取数据
                if(newValue) this.getData();
            },
            immediate:true,
        },
    },
    methods: {
        findDetail(item){
            uni.navigateTo({
                url: '/pages/yf_manage/views/detailTwo?rid='+item["挂单号"]+
                "&name="+item["姓名"],
            });
        },
        getData(){  //获取数据
            if(this.loading) return;  //如果正在加载则返回
            this.loading = true;
            getPayUpUsers().then(data=>{
                this.dataList = data;
            }).finally(()=>{
                this.loading=false;
            }).catch(msg=>{
                this.$refs.uToast.show({
                    title: msg,
                    position:'top',
                    type: 'error',
                });
            });
        },
    },
}
</script>
<style scoped lang="scss">
    .yfyp_cp{
        height: calc(100vh - 90rpx);
        .container{
            padding: 35rpx;
            box-sizing: border-box;
            .title{
                width: fit-content;
                font-size: 45rpx;
                color: #000000;
                font-weight: bold;
                margin-bottom: 35rpx;
            }
            >.two{
                margin-bottom: 35rpx;
            }
        }
    }
</style>
